package br.edu.fa7.receita.async;

import android.app.ProgressDialog;
import android.os.AsyncTask;
import br.edu.fa7.receita.ui.CadastroUsuarioActivity;

public class CadastroUsuarioAsyncTask extends AsyncTask<Void, Void, Void> {

	public CadastroUsuarioActivity cadastroUsuarioActivity;
	public ProgressDialog dialog; 
	
	public CadastroUsuarioAsyncTask(CadastroUsuarioActivity cadastroUsuarioActivity) {
		this.cadastroUsuarioActivity = cadastroUsuarioActivity;
		this.dialog = new ProgressDialog(this.cadastroUsuarioActivity);
	}

	
	@Override
	protected void onPreExecute() {
		dialog.setMessage("Salvando...");
		dialog.show();
	}
	
	@Override
	protected Void doInBackground(Void... params) {		
		cadastroUsuarioActivity.cadastrar();
		return null;
	}
	
	@Override
	protected void onPostExecute(Void result) {
		dialog.dismiss();
		cadastroUsuarioActivity.exibeMsgSucesso();
	}
}
